﻿using System;
using System.ComponentModel;

namespace DryWCS.Model.PLCModel
{
    public class StackerReadModel : INotifyPropertyChanged
    {
        private bool connected = false;
        public bool Connected
        {
            get { return connected; }
            set
            {
                connected = value;
                OnPropertyChanged("Connected");
            }
        }


        
        private Int16 status = 0;
        [PLCAttribute(Type = "Int16", StartPosition = 0, BitPosition = 0, Size = 0, Describe = "设备状态")]
        public  Int16 Status 
        { 
            get { return status; }
            set 
            { 
                status = value;
                OnPropertyChanged("Status");
            } 
        }


        
        private Int16 mode = 0;
        [PLCAttribute(Type = "Int16", StartPosition = 2, BitPosition = 0, Size = 0, Describe = "设备模式")]
        public Int16 Mode
         {
            get { return mode; }
            set
            {
                mode = value;
                OnPropertyChanged("Mode");
            }
         }


       
        private float position =  0;
        [PLCAttribute(Type = "float", StartPosition = 4, BitPosition = 0, Size = 0, Describe = "相对起点位置")]
        public float Position
        {
            get { return position; }
            set
            {
                position = value;
                OnPropertyChanged("Position");
            }
        }

        
        private Int16 lineNo = 0;
        [PLCAttribute(Type = "Int16", StartPosition = 8, BitPosition = 0, Size = 0, Describe = "当前排")]
        public Int16 LineNo
        {
            get { return lineNo; }
            set
            {
                lineNo = value;
                OnPropertyChanged("LineNo");
            }
        }

        
        private Int16 layerNo = 0;
        [PLCAttribute(Type = "Int16", StartPosition = 10, BitPosition = 0, Size = 0, Describe = "当前层")]
        public Int16 LayerNo
        {
            get { return layerNo; }
            set
            {
                layerNo = value;
                OnPropertyChanged("LayerNo");
            }
        }

        
        private Int16 colNo =0;
        [PLCAttribute(Type = "Int16", StartPosition = 12, BitPosition = 0, Size = 0, Describe = "当前列")]
        public  Int16 ColNo {
            get { return colNo; }
            set
            {
                colNo = value;
                //使用时用Message才能反应到控件中，直接给_message赋值不能直接反应到控件中
                OnPropertyChanged("ColNo");
            }
        }


        
        private Int16 forkStatus = 0;
        [PLCAttribute(Type = "Int16", StartPosition = 14, BitPosition = 0, Size = 0, Describe = "货叉动作")]
        public Int16 ForkStatus
        {
            get { return forkStatus; }
            set
            {
                forkStatus = value;
                OnPropertyChanged("ForkStatus");
            }
        }

       
        private int taskID = 0;
        [PLCAttribute(Type = "int", StartPosition = 16, BitPosition = 0, Size = 0, Describe = "当前任务ID")]
        public int TaskID
        {
            get { return taskID; }
            set
            {
                taskID = value;
                OnPropertyChanged("TaskID");
            }
        }
        
        private Int16 taskFeedback = 0;
        [PLCAttribute(Type = "Int16", StartPosition = 20, BitPosition = 0, Size = 0, Describe = "任务下发反馈")]
        public Int16 TaskFeedback
        {
            get { return taskFeedback; }
            set
            {
                taskFeedback = value;
                OnPropertyChanged("TaskFeedback");
            }
        }

       
        private Int16 taskStatus = 0;
        [PLCAttribute(Type = "Int16", StartPosition = 22, BitPosition = 0, Size = 0, Describe = "任务执行")]
        public Int16 TaskStatus
        {
            get { return taskStatus; }
            set
            {
                taskStatus = value;
                OnPropertyChanged("TaskStatus");
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string propertyName = "")
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
